<!DOCTYPE html>
<html lang="es">
<head>
	<meta http-equiv="Content-Type" content="text/html" ; charset="UTF-8" />
	<title>Ejercicio 3</title>
<script type="text/javascript">

	function ajax(dato) {
		var xmlhttp = new XMLHttpRequest();
		
		xmlhttp.open("GET","ajax.php?dato="+dato);
		xmlhttp.send();

		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState==4 && xmlhttp.status==200) {
				document.getElementById(dato).value = xmlhttp.responseText;
			}
		}
	}

	</script>
</head>
<body>

	<form action="" method="">
		<input type="button" onclick="ajax('pelicula')" value="Peli favorita">
		<input type="text" id="pelicula" disabled>
		<br />
		<input type="button" onclick="ajax('cancion')" value="Canción favorita">
		<input type="text" id="cancion" disabled>
	</form>

</body>
</html>